package com.jdk.learn.jvm;

/**
 * 垃圾回收
 * 引用计数器循环引用验证
 *
 *配置VM参数
 * -verbose:gc -XX:+PrintGCDetails

 *
 *
 */
public class _005GC {
    private  Object instance;

    public _005GC() {
        byte[] memory=new byte[20*1024*1024];
    }

    /**
     * "D:\Program Files\Java\jdk1.8.0_161\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:64430,suspend=y,server=n -verbose:gc -XX:+PrintGCDetails -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_161\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\rt.jar;D:\work\ideawork\mix_learn\target\classes;C:\Users\zdwljs\.m2\repository\org\springframework\spring-core\4.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-beans\4.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-context\4.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-expression\4.3.7.RELEASE\spring-expression-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-aspects\4.3.7.RELEASE\spring-aspects-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\aspectj\aspectjweaver\1.8.9\aspectjweaver-1.8.9.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-aop\4.3.7.RELEASE\spring-aop-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-web\4.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-tx\4.3.7.RELEASE\spring-tx-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-webmvc\4.3.7.RELEASE\spring-webmvc-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\springframework\spring-test\4.3.7.RELEASE\spring-test-4.3.7.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\redisson\redisson\3.3.2\redisson-3.3.2.jar;C:\Users\zdwljs\.m2\repository\io\netty\netty-common\4.1.8.Final\netty-common-4.1.8.Final.jar;C:\Users\zdwljs\.m2\repository\io\netty\netty-codec\4.1.8.Final\netty-codec-4.1.8.Final.jar;C:\Users\zdwljs\.m2\repository\io\netty\netty-buffer\4.1.8.Final\netty-buffer-4.1.8.Final.jar;C:\Users\zdwljs\.m2\repository\io\netty\netty-transport\4.1.8.Final\netty-transport-4.1.8.Final.jar;C:\Users\zdwljs\.m2\repository\io\netty\netty-resolver\4.1.8.Final\netty-resolver-4.1.8.Final.jar;C:\Users\zdwljs\.m2\repository\io\netty\netty-handler\4.1.8.Final\netty-handler-4.1.8.Final.jar;C:\Users\zdwljs\.m2\repository\javax\cache\cache-api\1.0.0\cache-api-1.0.0.jar;C:\Users\zdwljs\.m2\repository\io\projectreactor\reactor-stream\2.0.8.RELEASE\reactor-stream-2.0.8.RELEASE.jar;C:\Users\zdwljs\.m2\repository\io\projectreactor\reactor-core\2.0.8.RELEASE\reactor-core-2.0.8.RELEASE.jar;C:\Users\zdwljs\.m2\repository\org\reactivestreams\reactive-streams\1.0.0\reactive-streams-1.0.0.jar;C:\Users\zdwljs\.m2\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-yaml\2.8.7\jackson-dataformat-yaml-2.8.7.jar;C:\Users\zdwljs\.m2\repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;C:\Users\zdwljs\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.7\jackson-core-2.8.7.jar;C:\Users\zdwljs\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.7\jackson-databind-2.8.7.jar;C:\Users\zdwljs\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;C:\Users\zdwljs\.m2\repository\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar;C:\Users\zdwljs\.m2\repository\org\slf4j\slf4j-log4j12\1.6.6\slf4j-log4j12-1.6.6.jar;C:\Users\zdwljs\.m2\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar;C:\Users\zdwljs\.m2\repository\com\alibaba\fastjson\1.2.31\fastjson-1.2.31.jar;C:\Users\zdwljs\.m2\repository\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;C:\Users\zdwljs\.m2\repository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\zdwljs\.m2\repository\com\alibaba\druid\1.0.1\druid-1.0.1.jar;C:\Users\zdwljs\.m2\repository\mysql\mysql-connector-java\5.1.30\mysql-connector-java-5.1.30.jar;C:\Users\zdwljs\.m2\repository\net\sf\json-lib\json-lib\2.4\json-lib-2.4-jdk15.jar;C:\Users\zdwljs\.m2\repository\commons-beanutils\commons-beanutils\1.8.0\commons-beanutils-1.8.0.jar;C:\Users\zdwljs\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;C:\Users\zdwljs\.m2\repository\net\sf\ezmorph\ezmorph\1.0.6\ezmorph-1.0.6.jar;C:\Users\zdwljs\.m2\repository\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;C:\Users\zdwljs\.m2\repository\junit\junit\4.9\junit-4.9.jar;C:\Users\zdwljs\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar;C:\Users\zdwljs\.m2\repository\com\google\zxing\core\3.2.0\core-3.2.0.jar;C:\Users\zdwljs\.m2\repository\org\apache\commons\commons-email\1.3.1\commons-email-1.3.1.jar;C:\Users\zdwljs\.m2\repository\javax\mail\mail\1.4.5\mail-1.4.5.jar;C:\Users\zdwljs\.m2\repository\javax\activation\activation\1.1.1\activation-1.1.1.jar;C:\Users\zdwljs\.m2\repository\ch\ethz\ganymed\ganymed-ssh2\build210\ganymed-ssh2-build210.jar;C:\Users\zdwljs\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\zdwljs\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\zdwljs\.m2\repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\zdwljs\.m2\repository\cn\afterturn\easypoi-base\3.0.3\easypoi-base-3.0.3.jar;C:\Users\zdwljs\.m2\repository\org\apache\poi\poi\3.15\poi-3.15.jar;C:\Users\zdwljs\.m2\repository\org\apache\commons\commons-collections4\4.1\commons-collections4-4.1.jar;C:\Users\zdwljs\.m2\repository\org\apache\poi\poi-ooxml\3.15\poi-ooxml-3.15.jar;C:\Users\zdwljs\.m2\repository\com\github\virtuald\curvesapi\1.04\curvesapi-1.04.jar;C:\Users\zdwljs\.m2\repository\org\apache\poi\poi-ooxml-schemas\3.15\poi-ooxml-schemas-3.15.jar;C:\Users\zdwljs\.m2\repository\org\apache\xmlbeans\xmlbeans\2.6.0\xmlbeans-2.6.0.jar;C:\Users\zdwljs\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\Users\zdwljs\.m2\repository\com\google\guava\guava\16.0.1\guava-16.0.1.jar;C:\Users\zdwljs\.m2\repository\org\apache\commons\commons-lang3\3.2.1\commons-lang3-3.2.1.jar;C:\Users\zdwljs\.m2\repository\cn\afterturn\easypoi-web\3.0.3\easypoi-web-3.0.3.jar;C:\Users\zdwljs\.m2\repository\cn\afterturn\easypoi-annotation\3.0.3\easypoi-annotation-3.0.3.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.3.5\lib\idea_rt.jar" com.jdk.learn.jvm._005GC
     Connected to the target VM, address: '127.0.0.1:64430', transport: 'socket'
     [GC (System.gc()) [PSYoungGen: 22937K->776K(35840K)] 43417K->21264K(117760K), 0.0031155 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
     [Full GC (System.gc()) [PSYoungGen: 776K->0K(35840K)] [ParOldGen: 20488K->731K(81920K)] 21264K->731K(117760K), [Metaspace: 2850K->2850K(1056768K)], 0.0084979 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
     Heap
     Disconnected from the target VM, address: '127.0.0.1:64430', transport: 'socket'
     PSYoungGen      total 35840K, used 307K [0x00000000d8380000, 0x00000000dab80000, 0x0000000100000000)
     eden space 30720K, 1% used [0x00000000d8380000,0x00000000d83cce40,0x00000000da180000)
     from space 5120K, 0% used [0x00000000da180000,0x00000000da180000,0x00000000da680000)
     to   space 5120K, 0% used [0x00000000da680000,0x00000000da680000,0x00000000dab80000)
     ParOldGen       total 81920K, used 731K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000)
     object space 81920K, 0% used [0x0000000088a00000,0x0000000088ab6c98,0x000000008da00000)
     Metaspace       used 2857K, capacity 4486K, committed 4864K, reserved 1056768K
     class space    used 301K, capacity 386K, committed 512K, reserved 1048576K

     Process finished with exit code 0

     * @param args
     */
    public static void main(String[] args) {
        _005GC g1=new _005GC();
        _005GC g2=new _005GC();

        g1.instance=g2;
        g2.instance=g1;

        g1=null;
        g2=null;
        System.gc();//手动GC
    }

}
